package com.example.administrator.appstpremvpdemo.view.activity;

import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;

import com.example.administrator.appstpremvpdemo.R;
import com.example.administrator.appstpremvpdemo.adapter.myViewpagerAdapter;
import com.example.administrator.appstpremvpdemo.view.fragment.TempFragment;
import com.jcodecraeer.xrecyclerview.XRecyclerView;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Administrator
 * @Date 2017/12/27
 * @description
 * @function
 */

public class Activity5 extends AppCompatActivity {

    private XRecyclerView mXre;
    private Toolbar toolbar;
    private CollapsingToolbarLayout collapsingToolbar;
    private TabLayout tabLayout;
    private AppBarLayout appbar;
    private ViewPager viewpager;
    private myViewpagerAdapter adapter;
    private TabLayout.Tab mTab1;
    private TabLayout.Tab mTab2;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragent5);



        toolbar = (Toolbar) findViewById(R.id.toolbar);
        collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
        tabLayout = (TabLayout) findViewById(R.id.tabLayout);
        appbar = (AppBarLayout) findViewById(R.id.appbar);
        viewpager = (ViewPager) findViewById(R.id.viewpager);

        mTab1 = tabLayout.newTab();
        mTab2 = tabLayout.newTab();
        mTab1.setText("最新");
        mTab2.setText("热门");
        tabLayout.setSelectedTabIndicatorColor(getResources().getColor(android.R.color.holo_blue_bright));
        tabLayout.addTab(mTab1, true);
        tabLayout.addTab(mTab2, false);

        List<Fragment> list = new ArrayList<>();
        list.add(new TempFragment());
        list.add(new TempFragment());

        collapsingToolbar.setTitle("返回");
        collapsingToolbar.setExpandedTitleColor(Color.parseColor("#00ffffff"));//设置还没收缩时状态下字体颜色
        collapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);//设置收缩后Toolbar上字体的
        adapter = new myViewpagerAdapter(getSupportFragmentManager(), list);
        viewpager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewpager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);

        Uri uri = intent.getData();
        Log.w("Activity5", "uri:" + uri);
    }
}
